package org.jackysoft.struts2.portal;
import java.util.Collection;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Namespace;
import org.jackysoft.annotations.Logger;
import org.jackysoft.entity.nosql.NewsCatalog;
import org.jackysoft.service.NewsCatalogService;
import org.jackysoft.struts2.UtilsCRUDAction;
import org.jackysoft.util.OperationType;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


@Controller
@Namespace("/newscatalog")
@Scope(BeanDefinition.SCOPE_PROTOTYPE)
@Logger(label="新闻分类",logType=OperationType.User)
public class NewsCatalogAction 
extends UtilsCRUDAction<NewsCatalog> {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1269935761001220800L;
	private NewsCatalogService service;
	private NewsCatalog bean;
	private Collection<NewsCatalog> beans;
	
	
	public String catalog() throws Exception{
	    beans=service.getsByParent(bean.getId());
	    return BEANLIST;
	}
	
	public String listbyparent() throws Exception{
	
		zbeans = service.getsZtreeNodes(bean.getId());	
	    return ZBEANS;
	}
	
	public String toproot() throws Exception{
	    beans = service.getsByParent("root");
		return BEANLIST;
	}	
	
	public void setBean(NewsCatalog bean){
	     this.bean = bean;
	     
	}
	public NewsCatalog getBean(){
	     return this.bean;
	}
	public void setBeans(Collection<NewsCatalog> beans){
	
	     this.beans = beans;
	}
	public Collection<NewsCatalog> getBeans(){
	     return this.beans;
	}
	
	@Resource
	public void setService(NewsCatalogService service) {
		this.service = service;
		this.setDataProvider(service);
	}	
	
	public NewsCatalogService getService(){
	   return this.service;
	}
		
}